const adminAuth = (req, res, next) => {
  console.log('=== 管理员权限验证 ===');
  console.log('用户信息:', JSON.stringify(req.user, null, 2));
  console.log('用户角色:', req.user?.role);
  console.log('验证结果:', req.user && req.user.role === 'admin');

  if (req.user && req.user.role === 'admin') {
    next();
  } else {
    res.status(403).json({
      success: false,
      message: '需要管理员权限'
    });
  }
};

module.exports = adminAuth; 